home *** CD-ROM | disk | FTP | other *** search
/ QRZ! Ham Radio 1 / QRZ Ham Radio Callsign Database - December 1993.iso / ucsd / dsp / wefax.arc / WEFAX.C < prev    next >
Encoding:
C/C++ Source or Header  |  1988-02-16  |  1.5 KB  |  67 lines

  1. #include <stdio.h>
  2. #include <process.h>
  3. #include <graph.h>
  4. #include <dos.h>
  5. #define    CONTROL 0x34
  6. #define    CONT2 0xb4
  7.     unsigned prt0,cntrlpt,prt1,prt2;
  8.     int count,baseio,baseiop1;
  9. main(argc,argv)
  10. int argc;
  11. char *argv[];
  12. {
  13.     long count;
  14.     char freq[40];
  15.     double freqvco=5001.0,atof();
  16.     unsigned int freqint;
  17.     char *freqout=0xD0001FE0L;
  18.     baseio=0x300;
  19.     baseiop1 = baseio + 1;
  20.     cntrlpt = baseio + 7;
  21.     prt0 = baseio + 4;
  22.     prt2 = baseio + 6;
  23.     inp(cntrlpt);   /* halt */
  24.     printf("This program requires EGA capability, hit control C to stop,\n%s",
  25.     " hit any other key to continue\n");
  26.     count = 625 ;
  27.     /* set timers for desired sampling rate */
  28.     control_timer(count);
  29.     system("intel wefdemod d000 300 1");
  30.     printf("Do you wish to change the VCO frequency (y or n)? ");
  31.     while (kbhit() == 0) {};
  32.     freq[0]=getch();
  33.     if (freq[0]=='y') {
  34.         inp(cntrlpt);
  35.         while(freqvco>5000.0) {
  36.             printf("\nInput the frequency in Hz (<5000 Hz)? ");
  37.             gets(freq);
  38.             freqvco = atof(freq);
  39.             freqint = (freqvco * 1.6384 + 0.5);
  40.             memcpy(freqout,&freqint,2);
  41.             inp(0x306);
  42.         }
  43.     }
  44.     else printf("\n");
  45.     system("wefega");
  46.     inp(cntrlpt);
  47. }
  48.  
  49. control_timer(cnt)
  50. long cnt;
  51. {
  52.     unsigned int ctl,cth;
  53.     /* tell board timer info coming */
  54.     outp(cntrlpt ,CONTROL);
  55.     /* count is timing divisor */
  56.     ctl = cnt & 0xff;    /* lo byte */
  57.     cth = ( cnt >> 8 ) & 0xff;/* hi byte */
  58.     /* control timer 0 */
  59.     outp(prt0 , ctl);
  60.     outp(prt0 , cth);
  61.     /* control timer 2 */
  62.     outp(cntrlpt , CONT2);
  63.     outp(prt2 , ctl);
  64.     outp(prt2 , cth);
  65. }
  66.  
  67.